1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.tools.ant.input;
24
25 import java.util.Vector;
26
27 /***
28 * Encapsulates an input request.
29 * Modified for Antigen from the original Ant version
30 *
31 * @version $Revision: 1.2 $
32 * @since Ant 1.5
33 */
34 public class MultipleChoiceInputRequest extends InputRequest {
35 private Vector choices = new Vector();
36 private String theDefault;
37
38 /***
39 * @param prompt The prompt to show to the user. Must not be null.
40 * @param choices holds all input values that are allowed.
41 * Must not be null.
42 */
43 public MultipleChoiceInputRequest(String prompt, Vector choices) {
44 super(prompt);
45 if (choices == null) {
46 throw new IllegalArgumentException("choices must not be null");
47 }
48 this.choices = choices;
49 }
50
51 public MultipleChoiceInputRequest(String prompt, Vector choices, String theDefault) {
52 this(prompt, choices);
53 this.theDefault = theDefault;
54 }
55
56 public String getDefault() {
57 return theDefault;
58 }
59
60 /***
61 * @return The possible values.
62 */
63 public Vector getChoices() {
64 return choices;
65 }
66
67 /***
68 * @return true if the input is one of the allowed values.
69 */
70 public boolean isInputValid() {
71 return choices.contains(getInput());
72 }
73 }